package group2assignone.ucm.customer;

import group2assignone.model.Customer;
import group2assignone.ucm.UCController;
import group2assignone.view.MainView;
import group2assignone.view.OurView;
import group2assignone.view.customer.CustomerWelcomeView;
/**
 * Use Case: Change UI to Booking Confirmed
 * Pre-condition: user presses 'book flight' from the book flight view.
 * Post-condition: Booking Confirmed view is displayed, with the booking info.
 * 1. system creates a new flight 
 * 2. system uploads the flight info from the view.
 * 3. system creates the new Book Flight view
 * 4. system opens the new Book Flight view
 * 5. system exits the current view
 * @author group2
 */
/**
 * Use Case to display the 'booking confirmed' view
 * @author group2
 */
public class UCChangeUIBookingConfirmed implements UCController {

    private OurView view;
    private Customer customer;

    /**
     * The customer field is used to determine whether the customer
     * is logged in or if they are a 'guest'
     * @param view
     * @param customer
     */
    public UCChangeUIBookingConfirmed(Customer customer, OurView view) {
        this.view = view;
        this.customer = customer;
    }

    /**
     * Use Case: Change UI after Booking a Flight
     * 1. system exits current view
     * 2. system updates gui to the appropriate UI
     */
    public void run() {
        if (customer.getUsername().equals("Guest")) {
            MainView view1 = new MainView();
            view1.go();
        } else {
            CustomerWelcomeView view2 = new CustomerWelcomeView(customer);
            view2.go();
        }
        view.dispose();
    }
}
